import pygame
from typing import Tuple, Callable

from game.ui.base import BaseWidget
from game.world.coordinate import CoordinateType


class ButtonWidget(BaseWidget):

    def __init__(
            self,
            
            display_surface: pygame.Surface,
            
            surface: pygame.Surface,
            groups: Tuple[pygame.sprite.LayeredUpdates, ...],
            
            topleft: CoordinateType,
            bottomright: CoordinateType,
            
            on_click_callbacks: Tuple[Callable[[], None], ...] = ()
            
    ):
        super().__init__(display_surface, groups, on_click_callbacks)
        
        self.display_surface = display_surface
        
        self.surface = surface
        self.rect = self.surface.get_rect(topleft=topleft, bottomright=bottomright)

    def draw(self) -> None:
        if self.is_visible:
            self.display_surface.blit(self.surface, self.rect)

    def undraw(self) -> None:
        self.is_visible = False

    def set_visible(self):
        self.is_visible = True
    